package com.hsxc.cdz.monitor.bean;

/**
 * 报文的抽象类
 * @author 刘力文
 *
 */
public abstract class Msg <T extends Content>{
	
	/*************************************************************/
	//对象私有属性
	private String isOpen;        //启动字符 
	private int contentLength;    //报文长度
	private String isRegister;    //是否注册
	private String response;      //响应码
    private String operator;      //运营商
	private String address;       //设备地址
	private String frame;         //帧代码
	private String lineNum;       //流水号
	private T content;            //报文体
	
	//报文转换的长度
	protected static final int ISOPEN_LENGTH = 2;      //启动字符长度
	protected static final int CLENGTH_LENGTH = 2;     //报文长度的长度
	protected static final int ISREGISTER_LENGTH = 1;  //是否注册长度
	protected static final int RESPONSE_LENGTH = 3;    //响应码长度
	protected static final int OPERATOR_LENGTH = 2;    //运营商长度
	protected static final int ADDRESS_LENGTH = 8;     //设备地址长度
	protected static final int FRAME_LENGTH = 1;       //帧类型长度
	protected static final int LINE_LENGTH = 7;        //流水号长度
	
	public static final int headLength = 26;           //报文头长度
	
	/*************************************************************/
	//常量
	// 启动符
	public static final String START_UP = "6868";
	/*
	 * 判断是否注册的帧类型
	 */
	// 未注册
	public static final String NO_REGISTER = "00";
	// 已注册
	public static final String DID_REGISTER = "01";

	/*
	 * 响应码
	 */
	public static final String RESPONSE_NOMAL = "000000";
	public static final String RESPONSE_ERROR_RENAME = "FF0101";
	public static final String RESPONSE_ERROR_ACCOUNT = "FF0001";
	public static final String RESPONSE_ERROR_PASSWORD = "FF0002";
	public static final String RESPONSE_ERROR_COMMAND = "FFO2O1";
	
	/*************************************************************/
	//报文执行的抽象方法
	/**
	 * 执行报文的方法
	 * @return
	 */
	public abstract boolean execute ();
	
	
	/*************************************************************/
	//get() and set()
	public String getIsOpen() {
		return isOpen;
	}
	public void setIsOpen(String isOpen) {
		this.isOpen = isOpen;
	}
	public int getContentLength() {
		return contentLength;
	}
	public void setContentLength(int contentLength) {
		this.contentLength = contentLength;
	}
	public String getIsRegister() {
		return isRegister;
	}
	public void setIsRegister(String isRegister) {
		this.isRegister = isRegister;
	}
	public String getResponse() {
		return response;
	}
	public void setResponse(String response) {
		this.response = response;
	}
	public String getOperator() {
		return operator;
	}
	public void setOperator(String operator) {
		this.operator = operator;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getFrame() {
		return frame;
	}
	public void setFrame(String frame) {
		this.frame = frame;
	}
	public String getLineNum() {
		return lineNum;
	}
	public void setLineNum(String lineNum) {
		this.lineNum = lineNum;
	}
	public void setContent(T content) {
		this.content = content;
	}
	public T getContent() {
		return this.content;
	}
}
